#region Using Statements

using System.Collections.Generic;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using ZombieHigh2.GameState;
using ZombieHigh2.Viewport;
using Microsoft.Xna.Framework.Input;

#endregion

namespace ZombieHigh2.Screens
{
    public class IntroScreen : IGameState
    {
        Texture2D ZombieHead;
        Texture2D mainTitle;
        Vector2 ZombieHeadPos;
        float angle;
        SpriteBatch sb;
        bool switichToMenuScreen = false;

        ContentManager content;

        public ContentManager Content { get { return content; } }
        public bool IsPaused { get { return false; } }

        public IntroScreen(ContentManager content)
        {
            this.content = content;
        }

        public void LoadGraphics(GraphicsDevice device)
        {
            ZombieHead = content.Load<Texture2D>(@"Data\Images\intro_zombie_head");
            mainTitle = content.Load<Texture2D>(@"Data\Images\splashscreen");
            ZombieHeadPos = new Vector2(0, 250);
            angle = 0f;
            sb = new SpriteBatch(device);
        }

        public void Load()
        {
        }

        public void UnloadGraphics()
        {
        }

        public void Update(GameTime gameTime)
        {
            angle += 0.05f;
            ZombieHeadPos += new Vector2(2, 0);

            GamePadState gpadState = GamePad.GetState(PlayerIndex.One);

            if (gpadState.Buttons.Start == ButtonState.Pressed)
            {
                switichToMenuScreen = true;
            }
        }

        public void Draw(GraphicsDevice device)
        {
            if (switichToMenuScreen)
            {
                MenuScreen menuScreen = new MenuScreen(content);
                menuScreen.LoadGraphics(device);
                GameStateManager.Instance.PushState(menuScreen);
            }

            //device.Clear(Color.Black);
            device.Clear(Color.Red);
            sb.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.SaveState);
            sb.Draw(mainTitle, new Rectangle(0, 0, ViewportInfo.Instance.GetWidth, ViewportInfo.Instance.GetHeight), Color.White);
            sb.End();
            //sb.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.SaveState);
            //sb.Draw(ZombieHead, ZombieHeadPos, null, Color.White, angle, new Vector2(35,30), 1f, SpriteEffects.None, 0);
            //sb.End();
        }
    }
}
